Sample App: Me Chatbot
Medical App: DRR
Drr_ Health Recommendation App with GPT4
My Sample Chatbot App
Here’s the short Python code that I hooked into my sample Flask app.
This app assumes you have already indexed your text documents like this:
# Construct a simple vector index
= GPTSimpleVectorIndex(documents) index
# Import necessary packages
from llama_index import GPTSimpleVectorIndex, Document, SimpleDirectoryReader
import os
import openai
# import llama_index
import configparser
= configparser.ConfigParser()
config 'config.ini')
config.read(
= config.get('api_credentials', 'OPENAI_API_KEY')
openai_api_key
# Load the index from your saved index.json file
= GPTSimpleVectorIndex.load_from_disk('./data/neolifespragueindex.json')
index
## Ask Questions
# response = index.query("should I get a continuous glucose monitor?")
# print(response)
def respond_to_query(query, index_file):
# index = GPTSimpleVectorIndex.load_from_disk(index_file)
= index.query(query)
response return(response)
Inspired by this post on Medium by Guodong Zhao (paywalled) a step-by-step guide to build a chatbot for your own documents (copy on Evernote)